window.onload = function () {
    var username = document.querySelector("input[name='username']");
    var password = document.querySelector("input[name='psd']");
    var repwd = document.querySelector("input[name='repsd']");
    var tel = document.querySelector("input[name='tel']");
    var email = document.querySelector("input[name='email']");
    var btn_post = document.getElementById("btn");
    var span_remind = document.getElementsByTagName("div")[0][0];
    var span_remind1 = document.getElementsByTagName("div")[0][1];
    var span_remind2 = document.getElementsByTagName("div")[0][2];
    var span_remind3 = document.getElementsByTagName("div")[0][3];
    var span_remind4 = document.getElementsByTagName("div")[0][4];
    console.log(username);
    console.log(password);
    console.log(repwd);
    console.log(tel);
    console.log(email);
    console.log(btn_post);
    console.log(span_remind1);


    btn_post.onclick = function () {
        var username_regx = /^([A-Z]|[a-z]){4,12}$/;
        var password_regx = /\w{6,20}/;
        var tel_regx = /(^(13|14|15|17|18))\d{9}$/;
        var email_regx = /^(\w+(\_|\-|\.)*)+@(\w+(\-)?)+(\.\w{2,})+$/;
        if (username.value.match(username_regx)) {
            span_remind.innerHTML = null;
            span_remind.style.border = null;
        } else {
            span_remind.innerHTML = "长度4-12，英文大小写字母，请重新输入";
            span_remind.style.border = " 1px solid black";
        }

        if (password.value.match(password_regx)) {
            span_remind1.innerHTML = null;
            span_remind1.style.border = null;
        } else {
            span_remind1.innerHTML = "长度6-20，大小写字母、数字或下划线，请重新输入";
            span_remind1.style.border = "1px solid black"
        }

        if (password.value == repwd.value) {
            span_remind2.innerHTML = null;
            span_remind2.style.border = null;
        } else {
            span_remind2.innerHTML = "输入框不能为空，请重新输入";
            span_remind2.style.border = "1px solid black"
        }

        if (tel.value.match(tel_regx)) {
            span_remind3.innerHTML = null;
            span_remind3.style.border = null;
        } else {
            span_remind3.innerHTML = "13、14、15、17、18开头的11位手机号，请重新输入";
            span_remind3.style.border = "1px solid black";
        }

        if (email.value.match(email_regx)) {
            span_remind4.innerHTML = null;
            span_remind4.style.border = null;
        } else {
            span_remind4.innerHTML = "用户名@域名（域名后缀至少2个字符），请重新输入"
            span_remind4.style.border = "1px solid black";
        }
    }
}